import {get, put, post, fetchDelete} from "./request";

//获取全部试题类型
export const fetchQuestionType = (params, errorMessage) => {
    return get("/exam/question-type/list", params, errorMessage);
};
//获取全部试卷
export const fetchPaper = (params, errorMessage) => {
    return get("/exam/paper/page", params, errorMessage);
};
//获取更多试卷
export const fetchListPaper = (params, errorMessage) => {
    return get("/exam/paper/list-more-page", params, errorMessage);
};
//获取更多试卷
export const fetchList = (params, errorMessage) => {
    return get("/exam/paper/list", params, errorMessage);
};
//获取视频列表
export const fetchVideoList = (params, errorMessage) => {
    return get("/kc/course/video/chapter/list", {
        ...params,
        size: 1000,
        tree: false
    }, errorMessage);
};
//获取资料列表
export const fetchLiveList = (params, errorMessage) => {
    return get("/kc/course/live/list", {
        ...params,
        size: 1000,
        tree: false
    }, errorMessage);
};
export const fetchMaterialList = (params, errorMessage) => {
    return get("/material/info/list", {
        ...params,
        size: 1000,
        tree: false
    }, errorMessage);
};

export const fetchVideoId = (params, errorMessage) => {
    return get(
        `/kc/course/video/chapter/detail`,
        params,
        errorMessage
    );
};

export const fetchMaterialId = (params, errorMessage) => {
    return get(
        `/material/info/detail`,
        params,
        errorMessage
    );
};

export const fetchLiveId = (params, errorMessage) => {
    return get(
        `/kc/course/live/detail`,
        params,
        errorMessage
    );
};

export const saveColunmConfigId = (params, errorMessage) => {
    return get("/exam/paper/update-all", params, errorMessage);
};
//根据ids查询试题
export const fetchQuestionByIds = (params, errorMessage) => {
    return post("/exam/question/list-ids", params, errorMessage);
};
export const fetchQuestionByPaper = (params, errorMessage) => {
    return get("/exam/paper/questionList", params, errorMessage);
};
export const fetchQuestionCount = (params, errorMessage) => {
    return get("/exam/question/count", params, errorMessage);
};
export const getQuestionCount = (params, errorMessage) => {
    return get("/exam/question/getQuestionCount", params, errorMessage);
};
export const fetchExamById = (params, errorMessage) => {
    return get(
        `/exam/detail/${params.id}`,
        params,
        errorMessage
    );
}
export const releaseExam = (params, errorMessage) => {
    return post(
        `/exam/exam/release/${params.id}`,
        params,
        errorMessage
    );
}
export const fetchPaperByExamId = (params, errorMessage) => {
    return get(
        `/exam/exam/exam-paper/${params.id}`,
        params,
        errorMessage
    );
};
export const fetchPaperByRuleId = (params, errorMessage) => {
    return get(
        `/exam/rule/getPaper/${params.id}`,
        params,
        errorMessage
    );
};
export const insertExamPaperRe = (params, errorMessage) => {
    return post(
        `/exam/exam/re/update`,
        params,
        errorMessage
    );
};
export const fetchPaperId = (params, errorMessage) => {
    return get(
        `/exam/paper/detail`,
        params,
        errorMessage
    );
};
//通过考试关联表查询试卷或者规则详情
export const fetchResourceListByExamId = (params, errorMessage) => {
    return get(
        `/exam/exam/re/resource-list`,
        params,
        errorMessage
    );
};

export const fetchRuleId = (params, errorMessage) => {
    return get(
        `/exam/rule/detail/${params.id}`,
        params,
        errorMessage
    );
};
export const fetchRule = (params, errorMessage) => {
    return get("/exam/rule/page", params, errorMessage);
};

export const fetchExamId = (params, errorMessage) => {
    return get(
        `/exam/exam/detail/${params.id}`,
        params,
        errorMessage
    );
};

export const fetchColumnList = (params, errorMessage) => {
    return get("/exam/column/list", params, errorMessage);
};

export const fetchColumnById = (params, errorMessage) => {
    return get(`/exam/column/detail/${params.id}`, params, errorMessage);
};
export const fetchConfigIdById = (params, errorMessage) => {
    return get(`/exam/config/configIds`, params, errorMessage);
}

//导入试题
export const importQuestion = (data) =>
    post("/exam/question/add-source-collect", data);

//修改试题内容
export const updateQuestion = (data) =>
    put("/exam/question/update-question", data);

//写入试题
export const insertQuestion = (params, errorMessage) =>
    post("/exam/question/add-source-q", params, errorMessage);

//编辑试题
export const editQuestion = (params, errorMessage) =>
    put("/exam/question/update", params, errorMessage);

//删除试题
export const deleteQuestion = (params, errorMessage) =>
    fetchDelete("/exam/question/delete", params, errorMessage);

//查找试题
export const fetchSubject = (params, errorMessage) => {
    return get(
        `/exam/question/detail`,
        params,
        errorMessage
    );
};
//查找试题
export const fetchSubjectChild = (params, errorMessage) => {
    return get(
        `/exam/question/detail-child`,
        params,
        errorMessage
    );
};
// 查找章节
export const fetchChapterById = (params, errorMessage) => {
    return get(
        `/exam/chapter/detail/${params.id}`,
        params,
        errorMessage
    );
}

export const insertExamChapter = (params, errorMessage) => {
    return post(
        `/exam/chapters/update`,
        params,
        errorMessage
    );
};
export const updateExamChapter = (params, errorMessage) => {
    return put(
        `/exam/chapters/update`,
        params,
        errorMessage
    );
}
export const updateExam = (params, errorMessage) => {
    return put(
        `/exam/exam/update`,
        params,
        errorMessage
    );
}
export const addExamQuestionReBatch = (params, errorMessage) => {
    return post(
        `/exam/paper/questionList/insertBatch`,
        params,
        errorMessage
    );
}

//获取考试章节第一级
export const fetchChapterFirstStage = (params, errorMessage) => {
    return get(`/exam/chapters/getFirstStageByClassificationId`, params, errorMessage);
};

//获取考试章节子级
export const fetchChapterChildren = (params, errorMessage) => {
    return get(`/exam/chapters/getChildren`, params, errorMessage);
};

export const hidePapers = (params, errorMessage) => {
    return put(
        `/exam/paper/hide-list`,
        params,
        errorMessage
    );
}
// 修改试卷分类
export const updatePaperCategory = (params, errorMessage) => {
    return post(
        `/exam/paper/updatePaperCategory`,
        params,
        errorMessage
    );
}

export const getLazyChildren = (params, errorMessage) => {
    return get(`/exam/chapters/getLazyChildren`, params, errorMessage);
};

export const judgeCanUpdate = (params, errorMessage) => {
    return get(`/exam/question/judge-update`, params, errorMessage);
};
export const changeSkuAttrStatus = (params, errorMessage) => {
    return put(
        `/exam/package/sku/attr/changeStatus`,
        params,
        errorMessage
    );
}
export const changePackageStatus = (params, errorMessage) => {
    return put(
        `/exam/package/changeStatus`,
        params,
        errorMessage
    );
}
export const updatePackage = (params, errorMessage) => {
    return put(
        `/exam/package/update`,
        params,
        errorMessage
    );
}
export const changePackageSkuStatus = (params, errorMessage) => {
    return put(
        `/exam/package/sku/changeStatus`,
        params,
        errorMessage
    );
}
